<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  	<meta charset="utf-8">
  	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  	<title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-header">${basicName}字典</div>
			<div class="layui-card-body">
				<table class="layui-table" lay-filter="tableList" id="layerTable">
				</table>
			</div>
		</div>
	</div>

<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-primary layui-border-blue" onclick="add();">新增</button>
		<button class="layui-btn layui-btn-primary layui-border-blue" onclick="modi();">编辑</button>
		<button class="layui-btn layui-btn-primary layui-border-red" onclick="deleteBatch('/sys/paramBasicType/del/deleteByIds');">删除</button>
	</div>
</script>

<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-primary layui-border-red layui-btn-xs" lay-event="del">删除</a>
</script>

<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/common/core-2.0.0.js?v=${FILE_VERSION}"></script>
<script>
//JavaScript代码区域
var table;
var basicId = '${basicId}';
var basicName='${basicName}';
layui.use(['table'], function(){
  table = layui.table;
  table.render({ //其它参数在此省略
	  elem : '#layerTable',
	  even :"true",
	  toolbar: '#toolbar',
	  defaultToolbar: ['filter', 'exports', 'print'],
	  limit: 10,
	  limits: [10,30,50,100],
	  id: 'tableList',
	  url: getContextPath() + '/sys/paramBasicType/list/paramBasicTypeList',
	  page:true, 
	  where: {'basicId': basicId} ,
	  method: 'post', //如果无需自定义HTTP类型，可不加该参数
	  cols:  [[ //标题栏
         {checkbox: true, fixed: true}
		  ,{field:'basicId', width:120,sort: true,title:"大类编号"}
         ,{field:'basicName', width:160,title:"大类名称"}
         ,{field:'paramKey', width:120,title:"键"}
         ,{field:'paramValue', width:200,title:"值"}
		  ,{field:'sort', sort: true,title:"排序",width: 120}
         ,{field:'desp', title:"描述",minWidth: 160}
         ,{fixed: 'right', width:240, align:'center',title:"操作", toolbar: '#barDemo'}
       ]],
	  request: {
          pageName: 'current', //页码的参数名称，默认：page
          limitName: 'size' //每页数据量的参数名，默认：limit
	  } //如果无需自定义请求参数，可不加该参数
	});
  
  //监听工具条
  table.on('tool(tableList)', function(obj){
    var data = obj.data;
    if(obj.event === 'del'){
		deleteById(data,obj,'/sys/paramBasicType/del/deleteById');
    } else if(obj.event === 'edit'){
		addLayer('/sys/paramBasicType/edit/input', data.id);
    }
  });
});

function add(){
	addLayer('/sys/paramBasicType/add/input?basicId=' + basicId  + "&basicName" + basicName);
}

function modi(){
	var checkStatus = table.checkStatus('tableList')
			,data = checkStatus.data;
	if(data.length == 0 || data.length > 1){
		layer.msg("请选择一条数据");
		return false;
	}
	var url = getContextPath() +  '/sys/paramBasicType/edit/input?id=' + data[0].id + "&basicId=" + basicId  + "&basicName" + basicName;
	addLayer(url);
}

function reload(){
    table.reload('tableList');
}
</script>
</body>
</html>